<template>
  <div class="admin-container">
    <!-- 顶部导航栏 -->
    <header class="admin-header">
      <div class="header-title">
        <img src="/vite.svg" alt="外卖系统logo" class="logo">
        <span>外卖系统 - 管理员后台</span>
      </div>
      <div class="header-user">
        <span>管理员</span>
        <button class="logout-btn" @click="logout">退出登录</button>
      </div>
    </header>

    <!-- 主体内容 -->
    <div class="admin-main">
      <!-- 左侧菜单栏 -->
      <aside class="admin-sidebar">
        <ul class="sidebar-menu">
          <li class="menu-item">
            <i class="icon-user"></i>
            <router-link to="/admin/user">用户管理</router-link>
          </li>
          <li class="menu-item">
            <i class="icon-shop"></i>
            <router-link to="/admin/shop">商家管理</router-link>
          </li>
          <li class="menu-item">
            <i class="icon-rider"></i>
            <router-link to="/admin/rider">骑手管理</router-link>
          </li>
          <li class="menu-item">
            <i class="icon-order"></i>
            <router-link to="/admin/order">订单管理</router-link>
          </li>
          <li class="menu-item">
            <i class="icon-system"></i>
            <router-link to="/admin/system">系统管理</router-link>
          </li>
          <li class="menu-item">
            <i class="icon-data"></i>
            <router-link to="/admin/data">数据统计</router-link>
          </li>
        </ul>
      </aside>

      <!-- 右侧内容区 -->
      <main class="admin-content">
        <router-view></router-view>
      </main>
    </div>
  </div>
</template>

<script setup>

import router from "../../router.js";

const logout = () => {
  // 清除用户认证信息（如需要）
  // localStorage.removeItem('token')
  // 或其他登出逻辑

  // 跳转到登录页
  router.replace('/multilogin')
}
</script>

<style scoped>
/* 引入字体图标 */
@import url('https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.4.0/css/all.min.css');

.admin-container {
  display: flex;
  flex-direction: column;
  height: 100vh;
  background-color: #f5f7fa;
}

.admin-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0 30px;
  height: 60px;
  background-color: #4285f4;
  color: white;
  box-shadow: 0 2px 15px rgba(0, 0, 0, 0.1);
}

.header-title {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 20px;
  font-weight: bold;
}

.logo {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background-color: white;
  padding: 5px;
}

.header-user {
  display: flex;
  align-items: center;
  gap: 20px;
}

.logout-btn {
  padding: 8px 20px;
  background-color: #ea4335;
  color: white;
  border: none;
  border-radius: 4px;
  cursor: pointer;
  transition: background-color 0.3s;
}

.logout-btn:hover {
  background-color: #d33426;
}

.admin-main {
  display: flex;
  flex: 1;
  overflow: hidden;
}

.admin-sidebar {
  width: 220px;
  background-color: #fff;
  border-right: 1px solid #e0e0e0;
  box-shadow: 0 0 10px rgba(0, 0, 0, 0.05);
}

.sidebar-menu {
  list-style: none;
  padding: 0;
  margin: 0;
}

.menu-item {
  padding: 15px 25px;
  border-bottom: 1px solid #f0f0f0;
  transition: background-color 0.3s;
}

.menu-item:hover {
  background-color: #f5f7fa;
}

.menu-item a {
  color: #333;
  text-decoration: none;
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 16px;
}

.menu-item a:hover {
  color: #4285f4;
}

/* 图标样式 */
.icon-user::before {
  content: '\f007';
  font-family: 'Font Awesome 6 Free';
  font-weight: 900;
  color: #4285f4;
}

.icon-shop::before {
  content: '\f54e';
  font-family: 'Font Awesome 6 Free';
  font-weight: 900;
  color: #4285f4;
}

.icon-rider::before {
  content: '\f207';
  font-family: 'Font Awesome 6 Free';
  font-weight: 900;
  color: #4285f4;
}

.icon-order::before {
  content: '\f573';
  font-family: 'Font Awesome 6 Free';
  font-weight: 900;
  color: #4285f4;
}

.icon-system::before {
  content: '\f13e';
  font-family: 'Font Awesome 6 Free';
  font-weight: 900;
  color: #4285f4;
}

.icon-data::before {
  content: '\f201';
  font-family: 'Font Awesome 6 Free';
  font-weight: 900;
  color: #4285f4;
}

.admin-content {
  flex: 1;
  padding: 25px;
  overflow-y: auto;
  background-color: #f5f7fa;
}

/* 响应式设计 */
@media (max-width: 768px) {
  .admin-sidebar {
    width: 180px;
  }
  
  .header-title {
    font-size: 16px;
  }
}
</style>